<template>
  <div id="app">
    <ul>
      <li v-for="(item,index) in myArr" :key="index">{{ item }} <button @click="fn(index)">删除</button> </li>
    </ul>
    <button @click="btn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      myArr: [1, 2, 4],
    };
  },
  methods: {
    btn() {
    this.myArr.push(Math.floor(Math.random()*10))
    },
    fn(ind){
    this.myArr.splice(ind, 1);
    }
  },
};
</script>